<?php
  class RSS
  {
	public function RSS()
	{
		require_once ('db_conn.php');
	}

	public function GetFeed()
	{
		return $this->getDetails() . $this->getItems();
	}

	private function getDetails()
	{
		$detailsTable = "ninerr_gigs";
		$this->RSS($detailsTable);
		$query = "SELECT * FROM ". $detailsTable;
		$conn=@mysql_select_db(DBNAME,LINK);
		$result = mysql_query ($query);

		while($row = mysql_fetch_array($result))
		{
			$details = '<?xml version="1.0" encoding="ISO-8859-1" ?>
				<rss version="2.0">
					<channel>
						<title> '. SITE_TITLE.'</title>
						<link>'. $row["id"] .'</link>
						<description>'. SITE_NAME .'</description>
						<language>en-us</language>';
		}
		return $details;
	}

	private function getItems()
	{
		$itemsTable = "ninerr_gigs";
		$this->RSS($itemsTable);
		$query = "SELECT * FROM ". $itemsTable;
		$conn=@mysql_select_db(DBNAME,LINK);
		$result = mysql_query ($query);
		$items = '';
		while($row = mysql_fetch_array($result))
		{
$usersql="SELECT * FROM ninerr_user WHERE user_id =".$row["user_id"];

$conn1=@mysql_select_db(DBNAME,LINK);
$userget=mysql_query ($usersql);
$r1=mysql_fetch_array($userget);
$finaluser=$r1["user_name"];
$filtergig=str_replace(' ','-', $row["gigs_title"]);
$gigpage="users_".$finaluser."_gigs_".$filtergig;
if ($finaluser!=''){
                        $items .= '<item>
				<title>'.$finaluser.' will '. $row["gigs_title"] .'</title>
				<link>http://'.$_SERVER['HTTP_HOST'].'/'.$gigpage.'</link>
				<description><![CDATA['. $row["gigs_description"] .']]></description>
			           </item>';
}
		}
		$items .= '</channel>
				</rss>';
		return $items;
	}

}

?>
